package com.jms.web.getSql;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.jdbc.SQL;

public class GetSql {
    public String selectSql() {
        return new SQL(){
            {
                SELECT("*");
                FROM("student");

            }
        }.toString();
    }
    public String insertSql() {
        return new SQL(){
            {
                INSERT_INTO("student");
                INTO_VALUES("#{id},#{studentName},#{studentAge},#{cid}");
            }
        }.toString();
    }

    public String updateSql() {
        return new SQL(){
            {
                UPDATE("student");
                SET("name=#{studentName},age=#{studentAge},cid=#{cid}");
                WHERE("id=#{id}");
            }
        }.toString();
    }

    public String getDelete(){
        return new SQL(){
            {//代码块，代码块在编译时，会和构造方法合并到一起执行。
                DELETE_FROM("student");
                WHERE("id = #{id}");
            }
        }.toString();
    }
}
